<?
    final class Principio_View_Helper_CompaniesInAccounts extends Zend_View_Helper_Abstract
    {
        public function companiesInAccounts($expand = null)
        {
            $html = "<ul>";

            foreach ($this->view->collection_company->getListElementIterator() as $list_element_model_company)
            {
                $model_company = $list_element_model_company->getValue();

                $is_expand =  (!is_null($expand)) && (isset($expand['model_company'])) && ($expand['model_company']->getID() == $model_company->getID());

                $html .=  "<li class=\"has_content".($list_element_model_company->isLast() ? " last" : "")."\">";
                $html .= "<div class=\"node_pict ".($is_expand ? "opened" : "closed")."\" id=\"accounts_company_".$model_company->getID()."\" ";
                $html .= "onClick=\"expandMenu({id: 0, controller: 'accounts', company_id: ".$model_company->getID().", level: EXPAND_ACCOUNTS_IN_COMPANY});\"></div>";
                $html .= "<a href=\"\" onClick=\"ajaxViewByCompany({id: ".$model_company->getID().", action: 'short', use_inner: true, no_apply: true}); return false;\">";
                $html .= "<nobr>".$model_company->getCaption()."</nobr></a>";
                $html .= "<ul id=\"accounts_company_".$model_company->getID()."_content\" ".($is_expand ? "style=\"display: block;\"" : "").">";
                if ($is_expand)
                    $html .= $expand['expand'];
                $html .= "</ul></li>";
            };

            $html .= "</ul>";

            return $html;
        }
    };
?>